package thread;

public class TestLambda {
    //3静态内部类
    static class Like2 implements ILike{
        @Override
        public void lambda() {
            System.out.println("I LIKE LAMBDA2");
        }
    }

    public static void main(String[] args) {
        ILike like = new Like();
        like.lambda();
        like = new Like2();
        like.lambda();
        //4局部内部类
        class Like3 implements ILike{
            @Override
            public void lambda() {
                System.out.println("I LIKE LAMBDA3");
            }
        }
        like=new Like3();
        like.lambda();
        //匿名内部类，没有类的名称，必须借助接口或者父类
        like=new ILike(){
            @Override
            public void lambda() {
                System.out.println("I LIKE LAMBDA4");
            }
        };
        like.lambda();
        //6用Lambda简化
        like=()->{
            System.out.println("I LIKE LAMBDA5");
        };
        like.lambda();
    }
}

//1定义一个函数式接口
interface ILike{
    void lambda();
}

//2定义一个实现类
class Like implements ILike{
    @Override
    public void lambda() {
        System.out.println("I LIKE LAMBDA");
    }
}